home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 47.7z / BS1 part 47 / ImageMaster RT v1.50b (1994)(Black Belt Systems)(Disk 6 of 7)[HD].7z / ImageMaster RT v1.50b (1994)(Black Belt Systems)(Disk 6 of 7)[HD].adf / piarc.lzh.parta / cliprd.rexx < prev    next >
OS/2 REXX Batch file  |  1994-03-17  |  4KB  |  152 lines

  1. /*
  2.  * CLIPRD.rexx
  3.  *
  4.  *  Written by: Pete Patterson & Ben Williams
  5.  * Last Update: April 18, 1992
  6.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  7.  * ---------------------------------------------------------------------------
  8.  *    Revision: 1.02
  9.  */
  10. call pragma('stack',20000);
  11.  
  12. /*
  13.  * open rexxsupport.library -- needed for some functions
  14.  */
  15. if ~show('L',"rexxsupport.library") then do
  16.   if addlib('rexxsupport.library',0,-30,0) then do
  17.       /* everything's ok */
  18.     end;
  19.   else do
  20.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  21.     say 'Cannot operate CLIPRD.rexx without this library - sorry!';
  22.     exit 10;
  23.     end;
  24.   end;
  25.  
  26. /*
  27.  * This will automatically direct the script to the proper
  28.  * software, if it is running.
  29.  */
  30. prtnme = 'IP_Port'; /* assume Image Professional */
  31. if show('P','IP_Port') = 0 then do
  32.   if show('P','IM_Port') = 0 then do
  33.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  34.     say "This script requires IP, IM or IM F/c to run!";
  35.     exit(20);
  36.     end;
  37.   else do
  38.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  39.     end;                 /* We make em, user's break em.          */
  40.   end;
  41.  
  42.   /*
  43.    * This code attempts to read a file called "picmdpath" from REXX:
  44.    * If it can't find it, the script will assume that the commands
  45.    * associated with this PI Module are in "c:". If the file exists,
  46.    * the script will look in the path that is specified in the file.
  47.    * If you create this file, you MUST put a complete, correct path
  48.    * in it; if the commands are in a sub-directory, you have to put
  49.    * the trailing slash on the path (like, device:dir/).
  50.    * 
  51.    */
  52.   cmdpath = 'c:';
  53.   if open(fhandle,'rexx:picmdpath','read') then  /* open the file */
  54.     do
  55.       cmdpath = readln(fhandle);
  56.       call close(fhandle);  /* close the file    */
  57.     end
  58.  
  59. options;
  60. address;
  61.  
  62.   address(prtnme);
  63.   options results;
  64.   'current';
  65.   bufdata = result; /* get name of buffer, if there is one */
  66.   parse var bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum;
  67.   if bname ~= '<none>' then do
  68.     bufname = bname;
  69.     end;
  70.  
  71.   address(prtnme);
  72.  
  73.   'tofront';
  74.  
  75.   options results;
  76.   'asknumber '||'"Which clipboard unit?" 0'
  77.   unit = result;
  78.   'jackin';
  79.   jackadr = result;
  80.   options;
  81.  
  82.   options results;
  83.   address command cmdpath||'CLIPRD '||unit;
  84.   res = rc
  85.  
  86.   options;
  87.   if res = 0 then do
  88.     address(prtnme);
  89.     options results
  90.     'imagepath "ram:"';
  91.     'imageext  ".iff"';
  92.     'userload "im_clip"';
  93.     end;
  94.  
  95.   address(prtnme);
  96.   'imtofront';
  97.   address;
  98.  
  99.   exit 0;
  100.  
  101. /*
  102.  * gimmepath
  103.  *
  104.  * This takes the provided argument and sucks the path out of it, then
  105.  * returns that path to the caller, sans file name.
  106.  */
  107. gimmepath:
  108.   arg fullnamegx;
  109.     tempgx = reverse(fullnamegx);
  110.     lengx = length(fullnamegx);   /* get length of string */
  111.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  112.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  113.     seploc = 0; /* assumes current dir, no path supplied */
  114.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  115.       seploc = (lengx - slashdex)+1;
  116.       end;
  117.     else do
  118.       if colondex ~= 0 then do /* we assume we are on a device */
  119.         seploc = (lengx - colondex)+1;
  120.         end;
  121.       end;
  122.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  123.   gxpath = left(fullnamegx,seploc);
  124.   return(gxpath);
  125.  
  126. /*
  127.  * Since this script can't be expected to know where the CD of the user
  128.  * is when this cmd is invoked, we have to check the path the user
  129.  * provides - if it's not specified right from a root, then we have
  130.  * to make it a complete specification from the root.
  131.  */
  132. expandfilename:
  133.   parse arg jfile;
  134.   if index(jfile,':') = 0 then do
  135.     curdir = pragma(D);
  136.     if right(curdir,1) ~= ':' then do
  137.       if right(curdir,1) ~= '/' then do
  138.         if curdir ~= '' then do
  139.           curdir = curdir || '/';
  140.           end;
  141.         end;
  142.       end;
  143.     jfile = curdir||jfile;
  144.     end;
  145.   return(jfile);
  146.  
  147. rvalue:
  148.   wordnum = c2d(readch(fhandle,1)) * 256;
  149.   wordnum = wordnum + c2d(readch(fhandle,1));
  150.   return wordnum;
  151.  
  152.